I am having a problem with deleting a species of monkey as I cannot get round validation used when creating.
class MyMonkeysCollection extends \Phalcon\Mvc\Collection
{
use \Common\Models\Traits\MySoftDeleteable;
/**
*
* @var string
*/
public $family;
/**
*
* @var string
*/
public $genus;
/**
*
* @var string
*/
public $species;
/**
*
* @var string
*/
public $status;
public function validation()
{
if ($this->speciesNotUnique()) {
$message = new \Phalcon\Mvc\Model\Message(
"The species must be unique.",
"species",
"InvalidValue");
$this->appendMessage($message);
return false;
}
}
protected function speciesNotUnique()
{
$monkey = self::findFirst([["species" => $this->species]]);
if (isset($monkey->species)) {
return true;
}
return false;
}
}
When I $my_monkey->delete() then validation() is triggered.
How can skip validation() on delete() or what is the alternative?